package com.shawn.example.mvvmdemo.ui

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.jetpack.mvvm.lib.base.RouterConstant
import com.shawn.example.mvvmdemo.databinding.ActivityMainBinding
import com.jetpack.mvvm.lib.base.extention.appViewModules
import com.shawn.example.mvvmdemo.viewmodel.RepViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
    companion object {
        private const val TAG = "MainActivity"
    }
    private val viewModel: RepViewModel by appViewModules()
    private val binding: ActivityMainBinding by lazy {
        ActivityMainBinding.inflate(LayoutInflater.from(this))
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        ARouter.getInstance().inject(this)
        viewModel.getRepList()
        binding.btnJump.setOnClickListener {
            SecondActivity.start(this)
        }
        observerData()
    }

    private fun observerData() {
        viewModel.repListLiveData.observe(this) { label ->
            binding.tvLiveValue.text = "$label"
        }
    }
}